From 69d345b334c7a3fecdb0cd5f440fabd83a755309 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 18 Feb 2023 15:25:29 +0100 Subject: . --- src/routes/[lang=lang]/+page.server.ts | 14 +++- src/routes/[lang=lang]/+page.svelte | 19 +++--- src/routes/[lang=lang]/+page.ts | 2 +- src/routes/[lang=lang]/sections/contact.svelte | 69 ++++++++++++++++++++ src/routes/[lang=lang]/sections/description.svelte | 26 ++++++++ src/routes/[lang=lang]/sections/hero.svelte | 75 ++++++++++++++++++++++ src/routes/[lang=lang]/sections/products.svelte | 28 ++++++++ 7 files changed, 220 insertions(+), 13 deletions(-) create mode 100644 src/routes/[lang=lang]/sections/contact.svelte create mode 100644 src/routes/[lang=lang]/sections/description.svelte create mode 100644 src/routes/[lang=lang]/sections/hero.svelte create mode 100644 src/routes/[lang=lang]/sections/products.svelte (limited to 'src/routes/[lang=lang]') diff --git a/src/routes/[lang=lang]/+page.server.ts b/src/routes/[lang=lang]/+page.server.ts index 6e0a910..a647cfe 100644 --- a/src/routes/[lang=lang]/+page.server.ts +++ b/src/routes/[lang=lang]/+page.server.ts @@ -1,8 +1,10 @@ import { sanity } from '$lib/sanity-client'; import type { PageServerLoad } from './$types'; import groq from "groq"; -import type { ContactModel } from '$components/contact.svelte'; +import type { ContactModel } from './sections/contact.svelte'; import { fromLocalizedString } from '$lib/utils'; +import type { HeroModel } from './sections/hero.svelte'; +import type { DescriptionModel } from './sections/description.svelte'; export const load = (async ({ locals }) => { const contactSection = await sanity.fetch(groq`*[_type == "contact"][0]`); @@ -14,6 +16,14 @@ export const load = (async ({ locals }) => { email: fromLocalizedString(contactSection.email, locals.locale), phoneHours: fromLocalizedString(contactSection.phoneHours, locals.locale), addressLines: contactSection.addressLines.map((el: string | object) => fromLocalizedString(el, locals.locale)), - } as ContactModel + } as ContactModel, + hero: { + title: heroSection.title, + content: heroSection.content + } as HeroModel, + description: { + title: descriptionSection.title, + content: descriptionSection.content + } as DescriptionModel }; }) satisfies PageServerLoad; \ No newline at end of file diff --git a/src/routes/[lang=lang]/+page.svelte b/src/routes/[lang=lang]/+page.svelte index b757a71..325f085 100644 --- a/src/routes/[lang=lang]/+page.svelte +++ b/src/routes/[lang=lang]/+page.svelte @@ -1,16 +1,15 @@ - + + + + \ No newline at end of file diff --git a/src/routes/[lang=lang]/+page.ts b/src/routes/[lang=lang]/+page.ts index fa3907b..1ef0b57 100644 --- a/src/routes/[lang=lang]/+page.ts +++ b/src/routes/[lang=lang]/+page.ts @@ -13,6 +13,6 @@ export const load = (async ({ parent, data }) => { const $LL = get(LL) return { title: $LL.homeTitle(), - contact: data.contact + ...data } }) satisfies PageLoad; \ No newline at end of file diff --git a/src/routes/[lang=lang]/sections/contact.svelte b/src/routes/[lang=lang]/sections/contact.svelte new file mode 100644 index 0000000..b058180 --- /dev/null +++ b/src/routes/[lang=lang]/sections/contact.svelte @@ -0,0 +1,69 @@ + + + + +{#if visible} +
+
+
+

{$LL.contact.title()}

+
+ +
+
+
+ {#if (model.addressLines?.length ?? 0) > 0} +
+
{$LL.contact.addressTitle()}
+
+ {#each model.addressLines as line} + {line}
+ {/each} +
+
+ {/if} + {#if model.email} +
+
{$LL.contact.emailTitle()}
+
+ {model.email} +
+
+ {/if} + {#if model.phone} +
+
{$LL.contact.phoneTitle()}
+
+

{model.phone}

+ {#if model.phoneHours} +

{model.phoneHours}

+ {/if} +
+
+ {/if} +
+
+
+
+
+
+{/if} diff --git a/src/routes/[lang=lang]/sections/description.svelte b/src/routes/[lang=lang]/sections/description.svelte new file mode 100644 index 0000000..79a3939 --- /dev/null +++ b/src/routes/[lang=lang]/sections/description.svelte @@ -0,0 +1,26 @@ + + + + +{#if visible} +

{model.title}

+ {#if model.content} + + {/if} +{/if} diff --git a/src/routes/[lang=lang]/sections/hero.svelte b/src/routes/[lang=lang]/sections/hero.svelte new file mode 100644 index 0000000..3cdf221 --- /dev/null +++ b/src/routes/[lang=lang]/sections/hero.svelte @@ -0,0 +1,75 @@ + + + + +{#if visible} +
+
+
+
+

{model.title}

+ {#if model.content} + + {/if} +
+
+
+ +
+ +
+
+{/if} + + diff --git a/src/routes/[lang=lang]/sections/products.svelte b/src/routes/[lang=lang]/sections/products.svelte new file mode 100644 index 0000000..4e10b6f --- /dev/null +++ b/src/routes/[lang=lang]/sections/products.svelte @@ -0,0 +1,28 @@ + + + + +{#if visible} + +{/if} \ No newline at end of file -- cgit v1.3